const address = {
  area: "WuCheng",
  city: "JinHua",
  country: "China",
  state: "ZheJiang",
};

// 指定要序列化的字段以及序列化
console.log(JSON.stringify(address, ["country", "state", "city"])); // {"country":"China","state":"ZheJiang","city":"JinHua"}
// 指定替代函数
// {"city":"JinHua","country":"China","state":"ZheJiang"}
console.log(
  JSON.stringify(address, (k, v) => {
    return ["country", "state", "city", ""].includes(k) ? v : undefined;
  })
);
